#joint: GROUND, clamp, GROUND + RIGHT, node, node; # middle node

joint: GROUND, total pin joint,
    GROUND + RIGHT + 1,
        position, reference, GROUND, null, 
        position orientation, reference, GROUND, eye,
        rotation orientation, reference, GROUND, eye,
    #FUSELAGE,
        position, reference, GROUND, null,
        position orientation, reference, GROUND, eye,
        rotation orientation, reference, GROUND, eye,
    position constraint,
        1,
        1,
        1,
    null,
    orientation constraint,
        0,  # roll d.o.f.
        1,
        1,
        null;

# flap right
joint: FLAP_RIGHT + 1, total joint,
    GROUND + RIGHT + 1, 
        position, reference,  FLAP_RIGHT + 1, null,
        position orientation, reference,  FLAP_RIGHT + 1, eye,
        rotation orientation, reference, FLAP_RIGHT + 1, eye,
    FLAP_RIGHT + 1,
        position, reference, FLAP_RIGHT + 1, null,
        position orientation, reference, FLAP_RIGHT + 1, eye,
        rotation orientation, reference, FLAP_RIGHT + 1, eye,
    position constraint,
        1,
        1,
        1,
    null,
    orientation constraint,
        1,
        0,
        0,
        #null;
        component,
        #double step,
        #  T_START_FLAP_RIGHT,
        #  T_START_FLAP_RIGHT + T_PERIOD_FLAPRIGHT,
        #  DEG_FLAP_RIGHT,
        #  0.0,
        sine, T_START_FLAP_RIGHT, pi/T_PERIOD_FLAP_RIGHT, DEG_FLAP_RIGHT/2, forever, 0.0,
        0.0,
        0.0;		

joint: FLAP_RIGHT + 2, total joint,
    GROUND + RIGHT + 3, 
        position, reference, FLAP_RIGHT + 2, null,
        position orientation, reference,FLAP_RIGHT + 2, eye,
        rotation orientation, reference, FLAP_RIGHT + 2, eye,
    FLAP_RIGHT + 2,
        position, reference, FLAP_RIGHT + 2, null,
        position orientation, reference, FLAP_RIGHT + 2, eye,
        rotation orientation, reference, FLAP_RIGHT + 2, eye,
    position constraint,
        0,
        1,
        1,
    null,
    orientation constraint,
        0,
        0,
        0,
    null;	

joint: FLAP_RIGHT + 3, total joint,
    FLAP_RIGHT + 1, 
        position, reference, FLAP_RIGHT + 1, (FLAP_outboard-FLAP_inboard)/2, 0.0, 0.0,
        position orientation, reference, FLAP_RIGHT + 1, eye,
        rotation orientation, reference, FLAP_RIGHT + 1, eye,
    FLAP_RIGHT + 2,
        position, reference, FLAP_RIGHT + 1, (FLAP_outboard-FLAP_inboard)/2, 0.0, 0.0,
        position orientation, reference, FLAP_RIGHT + 1, eye,
        rotation orientation, reference, FLAP_RIGHT + 1, eye,
    position constraint,
        1,
        1,
        1,
    null,
    orientation constraint,
        1,
        1,
        1,
    null;

# flap left
joint: FLAP_LEFT + 1, total joint,
    GROUND + LEFT + 1, 
        position, reference,  FLAP_LEFT + 1, null,
        position orientation, reference,  FLAP_LEFT + 1, eye,
        rotation orientation, reference, FLAP_LEFT + 1, eye,
    FLAP_LEFT + 1,
        position, reference, FLAP_LEFT + 1, null,
        position orientation, reference, FLAP_LEFT + 1, eye,
        rotation orientation, reference, FLAP_LEFT + 1, eye,
    position constraint,
        1,
        1,
        1,
    null,
    orientation constraint,
        1,
        0,
        0,
        #null;
        component,
        #double step,
        #  T_START_FLAP_LEFT,
        #  T_START_FLAP_LEFT + T_PERIOD_FLAPLEFT,
        #  DEG_FLAP_LEFT,
        #  0.0,
        sine, T_START_FLAP_LEFT, pi/T_PERIOD_FLAP_LEFT, DEG_FLAP_LEFT/2, forever, 0.0,
        0.0,
        0.0;		

joint: FLAP_LEFT + 2, total joint,
    GROUND + LEFT + 3, 
        position, reference, FLAP_LEFT + 2, null,
        position orientation, reference,FLAP_LEFT + 2, eye,
        rotation orientation, reference, FLAP_LEFT + 2, eye,
    FLAP_LEFT + 2,
        position, reference, FLAP_LEFT + 2, null,
        position orientation, reference, FLAP_LEFT + 2, eye,
        rotation orientation, reference, FLAP_LEFT + 2, eye,
    position constraint,
        0,
        1,
        1,
    null,
    orientation constraint,
        0,
        0,
        0,
    null;	

joint: FLAP_LEFT + 3, total joint,
    FLAP_LEFT + 1, 
        position, reference, FLAP_LEFT + 1, -(FLAP_outboard-FLAP_inboard)/2, 0.0, 0.0,
        position orientation, reference, FLAP_LEFT + 1, eye,
        rotation orientation, reference, FLAP_LEFT + 1, eye,
    FLAP_LEFT + 2,
        position, reference, FLAP_LEFT + 1, -(FLAP_outboard-FLAP_inboard)/2, 0.0, 0.0,
        position orientation, reference, FLAP_LEFT + 1, eye,
        rotation orientation, reference, FLAP_LEFT + 1, eye,
    position constraint,
        1,
        1,
        1,
    null,
    orientation constraint,
        1,
        1,
        1,
    null;